<template>
	<div class="diy_home diy_list diy_expert_seating" id="diy_expert_seating_list">
		<!-- 列表 -->
		<div class="diy_view_list list list-x" v-if="show">
			<router-link class="diy_card goods diy_list_box_wrap" v-for="(o, i) in list" :key="i"
				:to="'/expert_seating/details?expert_seating_id=' + o['expert_seating_id']">
				<!-- 图片 -->
				<div class="diy_list_img_box" v-if="imgList.length" >
					<div class="diy_row" v-for="(item,index) in imgList" :key="item+index" v-show="$check_field('get',item.name,'/expert_seating/details') && +item.is_img_list">
						<div class="diy_title diy_list_img_title">
							<span>{{item.title}}:</span>
						</div>
						<div class="diy_field diy_img">
							<img :src="$fullUrl(o[item.name])" style="width:100%;height:100%" />
						</div>
					</div>
				</div>
				<!-- 内容 -->
				<div class="diy_list_item_box">
					<div class="diy_list_item_content" v-for="(item,index) in showItemList" :key="item+index">
						<div class="diy_row" :class="{[item.name]:true}" v-if="$check_field('get',item.name,'/expert_seating/details') && +item.is_img_list">
							<div class="diy_title">
								<span>{{item.title}}:</span>
							</div>
							<div class="diy_field diy_text">
								<span v-if="item.type == 'UID'" v-text="get_user_name(item.name,o[item.name])"></span>
								<span v-else-if="item.type == '日期'" v-text="$toTime(o[item.name],'yyyy-MM-dd')"></span>
								<span v-else-if="item.type == '时间'" v-text="$toTime(o[item.name],'hh:mm:ss')"></span>
								<span v-else-if="item.type == '日长'" v-text="$toTime(o[item.name],'yyyy-MM-dd hh:mm:ss')"></span>
								<span v-else v-text="o[item.name]"></span>
							</div>
						</div>
					</div>
				</div>
			</router-link>
		</div>
		<!-- 表格 -->
		<div class="diy_view_table" v-else>
			<table class="diy_table">
				<tr class="diy_row">
						<th class="diy_title" v-if="$check_field('get','meeting_number')">
						会议编号
					</th>
							<th class="diy_title" v-if="$check_field('get','conference_name')">
						会议名称
					</th>
							<th class="diy_title" v-if="$check_field('get','meeting_type')">
						会议类型
					</th>
							<th class="diy_title" v-if="$check_field('get','meeting_time')">
						会议时间
					</th>
							<th class="diy_title" v-if="$check_field('get','meeting_venue')">
						会议地点
					</th>
							<th class="diy_title" v-if="$check_field('get','participating_experts')">
						参会专家
					</th>
							<th class="diy_title" v-if="$check_field('get','expert_name')">
						专家姓名
					</th>
							<th class="diy_title" v-if="$check_field('get','seat_number')">
						座位号码
					</th>
					</tr>
				<tr class="diy_row" v-for="(o,i) in list" :key="o+i">
						<td class="diy_field diy_text" v-if="$check_field('get','meeting_number')">
						<span>
							{{ o["meeting_number"] }}
						</span>
					</td>
							<td class="diy_field diy_text" v-if="$check_field('get','conference_name')">
						<span>
							{{ $getBilingualText(o["conference_name"]) }}
						</span>
					</td>
							<td class="diy_field diy_text" v-if="$check_field('get','meeting_type')">
						<span>
							{{ $getBilingualText(o["meeting_type"]) }}
						</span>
					</td>
							<td class="diy_field diy_text" v-if="$check_field('get','meeting_time')">
						<span>
							{{ o["meeting_time"] }}
						</span>
					</td>
							<td class="diy_field diy_text" v-if="$check_field('get','meeting_venue')">
						<span>
							{{ $getBilingualText(o["meeting_venue"]) }}
						</span>
					</td>
							<td class="diy_field diy_uid" v-if="$check_field('get','participating_experts')">
						<span>
							{{ get_user_name('participating_experts',o['participating_experts']) }}
						</span>
					</td>
							<td class="diy_field diy_text" v-if="$check_field('get','expert_name')">
						<span>
							{{ o["expert_name"] }}
						</span>
					</td>
							<td class="diy_field diy_text" v-if="$check_field('get','seat_number')">
						<span>
							{{ o["seat_number"] }}
						</span>
					</td>
					</tr>
			</table>
		</div>
	</div>
</template>

<script>
	export default {
		props: {
			list: {
				type: Array,
				default: function() {
					return [];
				},
			},
			show: {
				type: Boolean,
				default: function(){
					return true;
				}
			}
		},
		data() {
			return {
						imgList: [
						],
						itemList: [
								{
									title: "会议编号",
									name: "meeting_number",
									type: "文本",
									is_img_list: "0"
								},
								{
									title: "会议名称",
									name: "conference_name",
									type: "文本",
									is_img_list: "0"
								},
								{
									title: "会议类型",
									name: "meeting_type",
									type: "文本",
									is_img_list: "0"
								},
								{
									title: "会议时间",
									name: "meeting_time",
									type: "文本",
									is_img_list: "0"
								},
								{
									title: "会议地点",
									name: "meeting_venue",
									type: "文本",
									is_img_list: "0"
								},
								{
									title: "参会专家",
									name: "participating_experts",
									type: "UID",
									is_img_list: "0"
								},
								{
									title: "专家姓名",
									name: "expert_name",
									type: "文本",
									is_img_list: "0"
								},
								{
									title: "座位号码",
									name: "seat_number",
									type: "文本",
									is_img_list: "0"
								},
						],
						richList: [
						],
										// 用户列表
				list_user_participating_experts: [],
						};
		},
		methods: {
			get_user_name(name,id){
				var obj = null;
										if (name == 'participating_experts'){
					obj = this.list_user_participating_experts.getObj({"user_id":id});
				}
							var ret = "";
				if(obj){
					ret = obj.nickname+"-"+obj.username;
					// if(obj.nickname){
					// 	ret = obj.nickname;
					// }
					// else{
					// 	ret = obj.username;
					// }
				}
				return ret;
			},
									/**
			 * 获取专家用户用户列表
			 */
			async get_list_user_participating_experts() {
				var json = await this.$get("~/api/user/get_list?user_group=专家用户");
				if(json.result && json.result.list){
					this.list_user_participating_experts = json.result.list;
				}
				else if(json.error){
					console.error(json.error);
				}
			},
					},
		created() {
									this.get_list_user_participating_experts();
					},
		computed:{
			showItemList(){
				let arr = [];
				let _type = ["视频","音频","文件"];
				this.itemList.forEach(item => {
					if(_type.indexOf(item.type) === -1 && !!+item.is_img_list){
						arr.push(item)
					}
				})
				return arr.slice(0,4);
			}
		}
	};
</script>

<style scoped>
	.media {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		flex-basis: 75%;
		min-height: 10rem;
	}

	.goods {
		display: flex;
		width: calc(25% - 1rem);
		margin: 0.5rem;
		padding: 0.5rem;
		flex-direction: column;
		justify-content: space-between;
		background-color: white;
		border-radius: 0.5rem;
	}

	.goods:hover {
		border: 0.2rem solid #909399;
		box-shadow: 0 0.1rem 0.3rem rgba(0, 0, 0, 0.15);
	}

	.goods:hover img {
		filter: blur(1px);
	}

	.price {
		font-size: 1rem;
		margin-right: 3px;
	}

	.price_ago {
		text-decoration: line-through;
		font-size: 0.5rem;
		color: #999;

	}

	.title {
		word-break: break-all;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		font-weight: 700;
		padding: .25rem;
	}

	.icon_cart {
		color: #FF5722;
		float: right;
	}

	@media (max-width: 992px) {

		.goods {
			width: calc(33% - 1rem);
			;
		}

	}

	@media (max-width: 768px) {

		.goods {
			width: calc(50% - 1rem);
			;
		}

	}
</style>

